#!/bin/bash

read -p "输入pod名称: " pd

arr=` kubectl get po -nfengchao|grep -v NAME|grep $pd|awk '{print $1}' `

for pod in $arr
do
    echo "-----------------取$pod日志中-------------------------------"
    dr=${pod%-*}	
    dr1=${dr%-*} 
    dr2=${pod##*-}
    mkdir -p $dr1/$dr2

    kubectl exec -nfengchao $pod -- yum -y install tar >/dev/null 2>&1
	
    kubectl cp fengchao/$pod:/var/log/zts $dr1/$dr2 >/dev/null 2>&1
    kubectl cp fengchao/$pod:logs $dr1/$dr2 >/dev/null 2>&1 
done